﻿using System;
using System.Runtime.CompilerServices;
using Manager;
using UniRx;
using UniRx.Triggers;
using UnityEngine;

namespace Studio
{
	// Token: 0x020004AA RID: 1194
	public class ShortcutKeyCtrl : MonoBehaviour
	{
		// Token: 0x06001DE1 RID: 7649 RVA: 0x000BD70C File Offset: 0x000BB90C
		public ShortcutKeyCtrl()
		{
            KeyCode[] array = new KeyCode[10];
            //RuntimeHelpers.InitializeArray(array, fieldof(< PrivateImplementationDetails >.$field - D6BA6896865F0AC0004C331AF3FEED735F78F322).FieldHandle);
            this.cameraKey = array;
            //base..ctor();
        }

		// Token: 0x06001DE2 RID: 7650 RVA: 0x000BD72C File Offset: 0x000BB92C
		private void Notification(int _id)
		{
			NotificationScene.spriteMessage = this.sprites[_id];
			NotificationScene.waitTime = 2f;
			NotificationScene.width = 416f;
			NotificationScene.height = 160f;
			//Singleton<Scene>.Instance.Load(new Scene.Data
			//{
			//	sceneName = "StudioNotification",
			//	isOverlap = true,
			//	isAdd = true,
			//	isLoading = false,
			//	isAsync = false,
			//	isFade = false
			//});
		}

		// Token: 0x06001DE3 RID: 7651 RVA: 0x000BD7A4 File Offset: 0x000BB9A4
		private void Start()
		{
			(from _ in this.UpdateAsObservable()
			where Singleton<Studio>.IsInstance()
			where !Singleton<Studio>.Instance.isInputNow
			where Singleton<Scene>.IsInstance()
			where Singleton<Scene>.Instance.addSceneName.IsNullOrEmpty()
			select _).Subscribe(delegate(Unit _)
			{
				bool flag = Input.GetKey(KeyCode.LeftControl) | Input.GetKey(KeyCode.RightControl);
				bool flag2 = Input.GetKey(KeyCode.LeftShift) | Input.GetKey(KeyCode.RightShift);
				if (flag2 & Input.GetKeyDown(KeyCode.Z))
				{
					if (Singleton<UndoRedoManager>.Instance.CanRedo)
					{
						Singleton<UndoRedoManager>.Instance.Redo();
					}
				}
				else if (Input.GetKeyDown(KeyCode.Z))
				{
					if (Singleton<UndoRedoManager>.Instance.CanUndo)
					{
						Singleton<UndoRedoManager>.Instance.Undo();
					}
				}
				else if (Input.GetKeyDown(KeyCode.F))
				{
					TreeNodeObject selectNode = this.treeNodeCtrl.selectNode;
					if (!(selectNode == null))
					{
						ObjectCtrlInfo objectCtrlInfo = null;
						if (Singleton<Studio>.Instance.dicInfo.TryGetValue(selectNode, out objectCtrlInfo))
						{
							this.cameraControl.targetPos = objectCtrlInfo.guideObject.transform.position;
						}
					}
				}
				else if (flag && Input.GetKeyDown(KeyCode.S))
				{
					this.systemButtonCtrl.OnClickSave();
				}
				else if (flag && Input.GetKeyDown(KeyCode.D))
				{
					Singleton<Studio>.Instance.Duplicate();
				}
				else if (Input.GetKeyDown(KeyCode.Delete))
				{
					this.workspaceCtrl.OnClickDelete();
				}
				else if (Input.GetKeyDown(KeyCode.W))
				{
					Singleton<GuideObjectManager>.Instance.mode = 0;
				}
				else if (Input.GetKeyDown(KeyCode.E))
				{
					Singleton<GuideObjectManager>.Instance.mode = 1;
				}
				else if (Input.GetKeyDown(KeyCode.R))
				{
					Singleton<GuideObjectManager>.Instance.mode = 2;
				}
				else if (Input.GetKeyDown(KeyCode.Q))
				{
					this.studioScene.cameraInfo.axis = !this.studioScene.cameraInfo.axis;
				}
				else if (Input.GetKeyDown(KeyCode.F11))
				{
					//Singleton<Sound>.Instance.Play(Sound.Type.SystemSE, "sound/data/systemse/00.unity3d", "sse_00_05", 0f, 0f, true, true, -1, true);
					this.gameScreenShot.Capture(string.Empty);
				}
				else if (Input.GetKeyDown(KeyCode.F2))
				{
					//if (Singleton<Manager.GameCursor>.IsInstance())
					//{
					//	Singleton<Manager.GameCursor>.Instance.SetCursorLock(false);
					//}
					//Singleton<Scene>.Instance.Load(new Scene.Data
					//{
					//	sceneName = "StudioShortcutMenu",
					//	isLoading = false,
					//	isAsync = false,
					//	isFade = false,
					//	isOverlap = false,
					//	isAdd = true
					//});
				}
				else if (Input.GetKeyDown(KeyCode.Escape))
				{
					if (Singleton<Manager.GameCursor>.IsInstance())
					{
						Singleton<Manager.GameCursor>.Instance.SetCursorLock(false);
					}
					Singleton<Scene>.Instance.GameEnd(true);
				}
				else
				{
					bool flag3 = false;
					for (int i = 0; i < 10; i++)
					{
						if (Input.GetKeyDown(this.cameraKey[i]))
						{
							this.studioScene.OnClickLoadCamera(i);
							flag3 = true;
							break;
						}
					}
					if (flag3)
					{
					}
				}
			}).AddTo(this);
		}

		// Token: 0x0400206E RID: 8302
		[SerializeField]
		private StudioScene studioScene;

		// Token: 0x0400206F RID: 8303
		[SerializeField]
		private SystemButtonCtrl systemButtonCtrl;

		// Token: 0x04002070 RID: 8304
		[SerializeField]
		private WorkspaceCtrl workspaceCtrl;

		// Token: 0x04002071 RID: 8305
		[SerializeField]
		private CameraControl cameraControl;

		// Token: 0x04002072 RID: 8306
		[SerializeField]
		private TreeNodeCtrl treeNodeCtrl;

		// Token: 0x04002073 RID: 8307
		[SerializeField]
		private GameScreenShot gameScreenShot;

		// Token: 0x04002074 RID: 8308
		[SerializeField]
		private Sprite[] sprites;

		// Token: 0x04002075 RID: 8309
		private readonly KeyCode[] cameraKey;
	}
}
